import 'package:flutter/material.dart';
import 'package:flutter_bilibili/util/color_util.dart';

/// 顶部tab切换组件
class HiTab extends StatelessWidget {
  final List<Widget> tabs;
  final TabController controller;
  final double fontSize;
  final double borderWidth;
  final double insets;
  final Color unselectedLabelColor;
  final BorderRadius? indicatorBorderRadius;

  const HiTab(
    this.tabs, {
    super.key,
    required this.controller,
    this.fontSize = 16,
    this.borderWidth = 3,
    this.insets = 15,
    this.unselectedLabelColor = Colors.black54,
    this.indicatorBorderRadius,
  });

  @override
  Widget build(BuildContext context) {
    return TabBar(
      controller: controller,
      isScrollable: true,
      labelColor: primary,
      unselectedLabelColor: unselectedLabelColor,
      labelStyle: TextStyle(fontSize: fontSize),
      indicator: UnderlineTabIndicator(
        borderRadius: indicatorBorderRadius,
        borderSide: BorderSide(color: primary, width: borderWidth),
        insets: EdgeInsets.only(left: insets, right: insets),
      ),
      tabs: tabs,
    );
  }
}
